package com.nitty.cash.loop.ui.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.lib.common.adapter.CommonRecyclerViewAdapter
import com.lib.common.adapter.CommonViewHolderHelper
import com.nitty.cash.loop.R
import org.json.JSONObject

/**
 * NittyCash
 * @Author wwdeng
 * @CreateTime: 2024/11/28 10:55
 * @Annotation：主页Tab
 */
class NittyTabAdapter(recyclerView: RecyclerView?) : CommonRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.ui_nitty_tab_item) {

    override fun setItemChildListener(helper: CommonViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.tabItemLayout)
    }

    override fun fillData(helper: CommonViewHolderHelper, position: Int, model: JSONObject) {
        val imgTab = helper.getImageView(R.id.imgTab)
        val textTab = helper.getTextView(R.id.textTab)
        textTab.text = model.optString("tabTitle")
        when(model.optBoolean("isSelect", false)){
            true -> {
                imgTab.setImageResource(model.optInt("tabSelectedIcon"))
                textTab.setTextColor(Color.parseColor("#FFFD5118"))
            }
            else -> {
                imgTab.setImageResource(model.optInt("tabNormalIcon"))
                textTab.setTextColor(Color.parseColor("#FFADB4CC"))
            }
        }
    }
}